import React from 'react'
import { Link } from 'react-router-dom'
import { ProductContext } from '@/App'
import ProductItem from '../components/Product'
export default function List() {
  return (
    <div>
      <Link to="/">返回主页</Link>
      <h1>全部商品</h1>
      <ProductContext.Consumer>
        {
          (products) => (
            products && products.map(item => (
              <ProductItem key={item.id} data={ item } />
            ))
          )
        }
      </ProductContext.Consumer>
    </div>
  )
}
